package org.example.server.controller;

import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.javassist.tools.rmi.ObjectNotFoundException;
import org.example.common.result.Result;
import org.example.dto.OrderDTO;
import org.example.dto.RegisterDTO;

import org.example.dto.RegisterDetailDTO;
import org.example.dto.RegisterListDTO;
import org.example.server.service.RegisterService;
import org.example.vo.OrderVO;
import org.example.vo.RegisterDetailVO;
import org.example.vo.RegisterListVO;
import org.example.vo.RegisterVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/v1/register")
public class RegisterController {

    @Resource
    private RegisterService registerService;

    //挂号预约
    @PostMapping("/appoint")
    private Result<RegisterVO> registerAppoint(@RequestBody RegisterDTO registerDTO) {
        log.info("挂号预约");

        RegisterVO registerVO = registerService.appoint(registerDTO);
        return Result.success(registerVO);
    }

    //挂号支付
    @PostMapping("/order")

    private Result<OrderVO> registerOrder(@RequestBody OrderDTO orderDTO)  {
        log.info("挂号支付");
        OrderVO orderVO = registerService.order(orderDTO);

        log.info("返回值：{}",orderVO);
        return Result.success(orderVO);
    }

    //挂号列表查询
    @PostMapping("/list")

    private Result<List<RegisterListVO>> selectList(@RequestBody RegisterListDTO registerListDTO) {
        log.info("挂号列表查询");
        List<RegisterListVO> registerListVO = registerService.selectList(registerListDTO);

        return Result.success(registerListVO);
    }

    //挂号详情查询
    @PostMapping("/detail")
    private Result<RegisterDetailVO> selectDetail(@RequestBody RegisterDetailDTO registerDetailDTO) {
        log.info("挂号详情查询");
        RegisterDetailVO registerDetailVO = registerService.selectDetail(registerDetailDTO);
    return Result.success(registerDetailVO);
    }
}
